using System;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Security;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Xsl;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.WebPartPages.Communication;
using Mvp.Xml.Exslt;


namespace PS.WebParts
{
    [XmlRoot(Namespace = "PS.WebParts.Rollup"), ToolboxData("<{0}:RollUp runat=server></{0}:RollUp>")]
    public class RollUp : WebPart, ICellConsumer, ICellProvider
    {
        // Events
        public event CellConsumerInitEventHandler CellConsumerInit;
        public event CellProviderInitEventHandler CellProviderInit;
        public event CellReadyEventHandler CellReady;

        // Fields
        /*
                private const string a_var = "";
        */
        private string aa;

        private CellConsumerInitEventHandler ab = null;
        private CellProviderInitEventHandler ad = null;
        private CellReadyEventHandler ae = null;

        private int ac;


        //private DataViewWebPart af;
        private static string ag;
        private DataSet dsData;
        private SPSite site;
        private string topLevel;
        private string lists;
        private string fields;
        private bool subSites;
        private bool includeData;
        private string xsl;
        private string query;
        private string k;
        private bool queryRecursive;
        private bool m;
        private bool queryModerator;
        private bool fixLookups;
        private bool showIsoDate;
        private string queryRowLimit;
        private string pageQueryString;
        private bool doDebug;
        private bool doDebugQuery;
        //private string u;
        private string v;
        private string w;
        private TextBox x;
        private string y;
        private string z;

        static RollUp()
        {
            ag = "";
        }

        public RollUp()
        {
            this.site = null;
            this.topLevel = "";
            this.lists = "";
            this.fields = "";
            this.subSites = false;
            this.includeData = false;
            this.xsl = "";
            this.query = "";
            this.k = "";
            this.queryRecursive = false;
            this.m = false;
            this.queryModerator = false;
            this.fixLookups = false;
            this.showIsoDate = false;
            this.queryRowLimit = "";
            this.pageQueryString = "";
            this.doDebug = false;
            this.doDebugQuery = false;
            //this.u = "";
            this.v = "";
            this.w = "";
            this.y = "Cell Data";
            this.z = "";
            this.aa = "";
            this.ac = 0;
            base.Load += new EventHandler(this.b);
        }


        /*
                private SPWeb GetWeb()
                {
                    SPWeb web2 = SPControl.GetContextWeb(base.Context);
                    SPWeb web1 = web2;
                    while (!web1.IsRootWeb)
                    {
                        web1 = web1.ParentWeb;
                    }
                    return web1;
                }
        */


        private string GetCompleteQuery(string query)
        {
            XmlDocument document1 = new XmlDocument();
            document1.LoadXml("<query>" + query + "</query>");
            StringBuilder builder1 = new StringBuilder();
            XmlTextWriter writer1 = new XmlTextWriter(new StringWriter(builder1));
            writer1.Formatting = Formatting.Indented;
            document1.WriteTo(writer1);
            writer1.Close();
            return builder1.ToString();
        }


        private DataSet GetDataSet(string[] columns)
        {
            DataSet set1 = new DataSet("Rows");
            DataTable table1 = new DataTable("Row");
            if (this.includeData)
            {
                table1.Columns.Add(new DataColumn("_ListTitle", typeof(string)));
                table1.Columns.Add(new DataColumn("_ListUrl", typeof(string)));
                table1.Columns.Add(new DataColumn("_SiteTitle", typeof(string)));
                table1.Columns.Add(new DataColumn("_SiteUrl", typeof(string)));
                table1.Columns.Add(new DataColumn("_ItemId", typeof(string)));
                table1.Columns.Add(new DataColumn("_ItemUrl", typeof(string)));
                table1.Columns.Add(new DataColumn("_ItemEdit", typeof(string)));
            }
            foreach (string text1 in columns)
            {
                table1.Columns.Add(new DataColumn(text1, typeof(string)));
            }
            set1.Tables.Add(table1);
            return set1;
        }

        /*
                private static string ConvertDate(Match A_0)
                {
                    string text1 = A_0.Groups[1].ToString();
                    DateTime time1 = DateTime.Parse(RollUp.c());
                    time1 = time1.AddDays(Convert.ToDouble(text1));
                    return SPUtility.CreateISO8601DateTimeFromSystemDateTime(time1);
                }
        */


        private SPWeb GetWeb(SPSite site, string url)
        {
            try
            {
                return site.OpenWeb(url);
            }
            catch
            {
                SPWeb web2 = SPControl.GetContextWeb(this.Context);
                return web2.Webs[url];
            }
        }


        private bool CanViewListItems(SPList list)
        {
            try
            {
                list.Permissions.CheckPermissions(SPRights.ViewListItems);
                return true;
            }
            catch
            {
                return false;
            }
        }


        private void WalkSiteCollection(SPWebCollection webs, string listName)
        {
            try
            {
                foreach (SPWeb web1 in webs)
                {
                    this.ProcessList(this.dsData.Tables["Row"], web1, listName, this.fields.Split(new char[] { ',' }));
                    this.WalkSiteCollection(web1.GetSubwebsForCurrentUser(), listName);
                }
            }
            catch (Exception)
            {
            }
        }


        private void TextChanged(object o, EventArgs e)
        {
        }


        private void WriteException(HtmlTextWriter writer, Exception exception)
        {
            writer.Write("<font color=red><b>ERROR:</b><br>");
            writer.Write(exception.Message);
            writer.Write("<br>");
            writer.Write(exception.StackTrace);
            if (this.v != "")
            {
                writer.Write("<br><b>Debug Info</b></br>");
                writer.Write(this.v);
            }
            writer.Write("</font>");
        }


        /*
                private void Write(HtmlTextWriter A_0, string A_1)
                {
                    A_0.Write("<font color=blue>" + A_1 + "</font><br>");
                }
        */


        private SPQuery GetQuery(string str, SPWeb web)
        {
            SPQuery query1 = new SPQuery();
            RollUp.ag = this.z;
            str = str.Replace("[Login]", web.CurrentUser.LoginName);
            str = str.Replace("[UserName]", web.CurrentUser.Name);
            str = str.Replace("[UserID]", web.CurrentUser.ID.ToString());
            str = str.Replace("[CellProvider]", RollUp.c());
            str = str.Replace("[Now]", DateTime.Now.ToString("u"));
            str = str.Replace("[SNow]", DateTime.Now.ToShortDateString());
            DateTime time1 = DateTime.Now.AddDays((double)(-DateTime.Now.Day + 1));
            str = str.Replace("[FirstMonthDay]", time1.ToString("u"));
            time1 = DateTime.Now.AddDays((double)(-DateTime.Now.Day + 0x1f));
            str = str.Replace("[LastMonthDay]", time1.ToString("u"));
            str = Regex.Replace(str, @"\[Now([+-][\d]+)\]", new MatchEvaluator(RollUp.GetISODate));
            query1.Query = str;
            if (this.queryRecursive)
            {
                query1.ViewAttributes = "Scope='Recursive' ";
            }
            if (this.m)
            {
                query1.ViewAttributes = query1.ViewAttributes + " RecurrenceRowset='TRUE' ";
            }
            if (this.queryModerator)
            {
                query1.ViewAttributes = query1.ViewAttributes + " ModerationType='Moderator' ";
            }
            if (this.queryRowLimit.Length > 0)
            {
                query1.RowLimit = Convert.ToUInt32(this.queryRowLimit);
            }
            query1.IncludeMandatoryColumns = true;
            this.k = query1.Query;
            return query1;
        }


        private void ProcessList(DataTable dataTable, SPWeb web, string listName, string[] columns)
        {
            try
            {
                SPList list1 = web.Lists[listName];
                if (!this.CanViewListItems(list1))
                {
                    return;
                }
                SPListItemCollection collection1 = null;
                try
                {
                    if (this.query.Length > 0)
                    {
                        collection1 = list1.GetItems(this.GetQuery(this.query, web));
                    }
                    else
                    {
                        collection1 = list1.Items;
                    }
                }
                catch (Exception exception1)
                {
                    string text3 = this.w;
                    this.w = string.Concat(new string[] { text3, "Error: In Query <br>", this.GetCompleteQuery(this.k), "<br><br>", exception1.ToString() });
                }
                if (collection1 == null)
                {
                    return;
                }
                foreach (SPListItem item1 in collection1)
                {
                    DataRow row1 = dataTable.NewRow();
                    if (this.includeData)
                    {
                        row1["_ListTitle"] = list1.Title;
                        row1["_ListUrl"] = list1.DefaultViewUrl;
                        row1["_SiteTitle"] = web.Title;
                        row1["_SiteUrl"] = web.Url;
                        row1["_ItemId"] = item1.ID;
                        row1["_ItemUrl"] = list1.DefaultViewUrl.Substring(0, list1.DefaultViewUrl.LastIndexOf('/')) + "/DispForm.aspx?ID=" + item1.ID;
                        row1["_ItemEdit"] = list1.DefaultViewUrl.Substring(0, list1.DefaultViewUrl.LastIndexOf('/')) + "/EditForm.aspx?ID=" + item1.ID;
                    }
                    try
                    {
                        foreach (string text1 in columns)
                        {
                            if (item1[text1] != null)
                            {
                                string text2 = SPEncode.HtmlDecode(item1[text1].ToString());
                                if (this.showIsoDate && (item1.Fields.GetField(text1).Type == SPFieldType.DateTime))
                                {
                                    text2 = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Parse(text2));
                                }
                                else if (this.fixLookups && (text2.IndexOf(";#") > 0))
                                {
                                    text2 = text2.Substring(text2.IndexOf(";#") + 2);
                                }
                                row1[text1] = text2;
                            }
                            else
                            {
                                row1[text1] = string.Empty;
                            }
                        }
                    }
                    catch (Exception exception2)
                    {
                        this.v = "<br/>Debug Error:  " + exception2.ToString();
                    }
                    dataTable.Rows.Add(row1);
                }
            }
            catch (Exception)
            {
            }
        }

        private string GetDebugContextInfo()
        {
            SPSite site1 = SPControl.GetContextSite(this.Context);
            SPWeb web1 = site1.RootWeb;
            string rootUrl = site1.Url;
            string portalUrl = site1.PortalUrl;
            string serverRelativeUrl = site1.ServerRelativeUrl;
            this.v = this.v + "<br/> Url:" + rootUrl;
            this.v = this.v + "<br/> PortalUrl:" + portalUrl;
            this.v = this.v + "<br/> RelativeUrl:" + serverRelativeUrl;
            if (portalUrl != serverRelativeUrl)
            {
                rootUrl = rootUrl.Replace(web1.ServerRelativeUrl, "");
            }
            this.v = this.v + "<br/>Url2:" + rootUrl;
            return rootUrl;
        }


        private static string GetISODate(Match match)
        {
            string text1 = match.Groups[1].ToString();
            DateTime time1 = DateTime.Now.AddDays(Convert.ToDouble(text1));
            return SPUtility.CreateISO8601DateTimeFromSystemDateTime(time1);
        }


        private void b(object o, EventArgs eventArgs)
        {
            if (this.Page.IsPostBack)
            {
                string text1 = this.Page.Request["__EVENTARGUMENT"];
                string text2 = this.Page.Request["__EVENTTARGET"];
                if ((text1 != null) && (text2 == this.ID))
                {
                    this.aa = SPEncode.HtmlDecode(text1);
                    this.ViewState["RollUpProvideValue"] = this.aa;
                }
                else
                {
                    this.aa = (string)this.ViewState["RollUpProvideValue"];
                }
            }
        }


        private void WriteError(HtmlTextWriter writer, string message)
        {
            writer.Write("<font color=red>" + message + "</font><br>");
        }


        private static string c()
        {
            return RollUp.ag;
        }

        public override ConnectionRunAt CanRunAt()
        {
            return ConnectionRunAt.Server;
        }

        protected override void CreateChildControls()
        {
            this.x = new TextBox();
            this.x.TextChanged += new EventHandler(this.TextChanged);
            this.x.AutoPostBack = true;
            this.x.Attributes.Add("style", "width: 0px; height: 0px; display: none; visibility: hidden");
            this.x.Text = this.aa;
            this.Controls.Add(this.x);
        }

        public override void CreateWebPartMenu()
        {
            base.WebPartMenu.MenuItems.Add(new Microsoft.SharePoint.WebPartPages.MenuItem("ideseg.com", "javascript:{var win = window.open('http://www.ideseg.com');}"));
            base.CreateWebPartMenu();
        }

        private void VisitSubSites()
        {
            SPWeb web1;
            string[] arrLists = this.lists.Split(new char[] { ',' });
            if (this.topLevel.Length > 0)
            {
                web1 = this.site.RootWeb;
            }
            else
            {
                web1 = SPControl.GetContextWeb(this.Context);
            }
            this.dsData = this.GetDataSet(this.fields.Split(new char[] { ',' }));
            foreach (string text1 in arrLists)
            {
                string text2 = text1;
                if (text1.LastIndexOf(':') > 0)
                {
                    string[] textArray2 = text1.Split(new char[] { ':' });
                    web1 = this.GetWeb(this.site, textArray2[0]);
                    text2 = textArray2[1];
                }
                this.ProcessList(this.dsData.Tables["Row"], web1, text2, this.fields.Split(new char[] { ',' }));
                this.WalkSiteCollection(web1.GetSubwebsForCurrentUser(), text2);
            }
        }

        private void VisitSite()
        {
            string[] textArray1 = this.lists.Split(new char[] { ',' });
            string[] textArray2 = this.fields.Split(new char[] { ',' });
            this.dsData = this.GetDataSet(textArray2);
            SPWeb web1 = SPControl.GetContextWeb(this.Context);
            string text1 = "";
            foreach (string text2 in textArray1)
            {
                text1 = text2;
                if (text2.LastIndexOf(':') > 0)
                {
                    string[] textArray3 = text2.Split(new char[] { ':' });
                    web1 = this.GetWeb(this.site, textArray3[0]);
                    text1 = textArray3[1];
                }
                this.ProcessList(this.dsData.Tables["Row"], web1, text1, textArray2);
            }
        }

        public override void EnsureInterfaces()
        {
            try
            {
                base.RegisterInterface("RollUpCellConsumer", "ICellConsumer", -1, ConnectionRunAt.Server, this, "", "Consumes a cell from", "Consumes a cell of data");
                base.RegisterInterface("RollUpCellProvider", "ICellProvider", -1, ConnectionRunAt.Server, this, "", "Provides a cell to", "Provides a cell of data");
            }
            catch (SecurityException)
            {
            }
        }

        public override InitEventArgs GetInitEventArgs(string interfaceName)
        {
            if (interfaceName == "RollUpCellConsumer")
            {
                this.EnsureChildControls();
                CellConsumerInitEventArgs args1 = new CellConsumerInitEventArgs();
                args1.FieldName = this.y;
                return args1;
            }
            return null;
        }


        public override ToolPart[] GetToolParts()
        {
            ToolPart[] partArray1 = new ToolPart[3];
            WebPartToolPart part1 = new WebPartToolPart();
            CustomPropertyToolPart part2 = new CustomPropertyToolPart();
            partArray1[0] = part2;
            partArray1[1] = part1;
            partArray1[2] = new Toolpart();
            return partArray1;
        }


        void ICellConsumer.CellProviderInit(object sender, CellProviderInitEventArgs cellProviderInitArgs)
        {
        }


        void ICellConsumer.CellReady(object sender, CellReadyEventArgs cellReadyArgs)
        {
            if (cellReadyArgs.Cell != null)
            {
                this.z = cellReadyArgs.Cell.ToString();
            }
        }

        void ICellProvider.CellConsumerInit(object sender, CellConsumerInitEventArgs cellConsumerInitArgs)
        {
        }

        public override void PartCommunicationConnect(string interfaceName, WebPart connectedPart, string connectedInterfaceName, ConnectionRunAt runAt)
        {
            this.EnsureChildControls();
            if (interfaceName == "RollUpCellConsumer")
            {
                this.ac++;
            }
        }
        public override void PartCommunicationInit()
        {
            if ((this.ac > 0) && (this.ab != null))
            {
                CellConsumerInitEventArgs args1 = new CellConsumerInitEventArgs();
                args1.FieldName = this.y;
                this.ab(this, args1);
            }
            if (this.ad != null)
            {
                CellProviderInitEventArgs args2 = new CellProviderInitEventArgs();
                args2.FieldName = this.y;
                this.ad(this, args2);
            }
        }

        public override void PartCommunicationMain()
        {
            if (this.ae != null)
            {
                CellReadyEventArgs args1 = new CellReadyEventArgs();
                args1.Cell = SPEncode.HtmlEncode(this.aa);
                this.ae(this, args1);
            }
        }
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            this.EnsureChildControls();
            this.x.RenderControl(output);
            try
            {
                SPControl.GetContextWeb(this.Context);
                //SPSite site1 = SPControl.GetContextSite(this.Context);
                //string text4 = site1.RootWeb.Url;
                string debugContextInfo = this.GetDebugContextInfo();
                //string text5 = site1.HostName;
                //output.Write(topLevel+":");
                if (this.topLevel.Length > 0)
                {
                    if (this.topLevel == "[CellProvider]")
                    {
                        if (this.z.Length > 0)
                        {
                            this.site = new SPSite(this.z);
                        }
                    }
                    else
                    {
                        this.site = new SPSite(this.topLevel);
                    }
                }
                else
                {
                    this.site = new SPSite(debugContextInfo);
                }
                
                if ((this.lists == "") || (this.fields == ""))
                {
                    this.WriteError(output, "Warning: Check RollUp properties");
                }
                else if (this.site != null)
                {
                    this.site.CatchAccessDeniedException = false;
                    if (this.subSites)
                    {
                        this.VisitSubSites();
                    }
                    else
                    {
                        this.VisitSite();
                    }
                    //string text2 = this.b_var.GetXml();
                    //this.u = text2;
                    if (this.doDebug)
                    {
                        output.Write("<font color=red>DEBUG XML</font><br><font color=blue>");
                        output.Write("<pre>" + SPEncode.HtmlEncode(this.dsData.GetXml()) + "</pre>");
                        output.Write("</font><br>");
                    }
                    if (this.doDebugQuery)
                    {
                        output.Write("<font color=red>DEBUG CAML Query</font><br><font color=blue>");
                        output.Write("<pre>" + SPEncode.HtmlEncode(this.GetCompleteQuery(this.k)) + "</pre>");
                        output.Write("</font><br>");
                    }
                    if (this.xsl != "")
                    {
                        this.xsl = this.xsl.Replace("__doPostBack(''", "__doPostBack('" + this.ID + "'");
                        this.xsl = this.xsl.Replace("[CellProvider]", this.aa);
                        this.xsl = this.xsl.Replace("[CellConsumer]", this.z);
                        XmlTextReader reader1 = new XmlTextReader(new StringReader(this.xsl));
                        ExsltTransform transform1 = new ExsltTransform();
                        transform1.Load(reader1, null);
                        XmlDataDocument document1 = new XmlDataDocument(this.dsData);
                        StringWriter writer1 = new StringWriter();
                        XmlTextWriter writer2 = new XmlTextWriter(writer1);
                        double num1 = 0;
                        if (this.Page.Request.QueryString["page"] != null)
                        {
                            num1 = double.Parse(this.Page.Request.QueryString["page"]);
                        }
                        XsltArgumentList list1 = new XsltArgumentList();
                        list1.AddParam("CurrentPage", string.Empty, num1);
                        list1.AddParam("RecordCount", string.Empty, this.dsData.Tables["Row"].Rows.Count);
                        transform1.SupportedFunctions = ExsltFunctionNamespace.All;
                        transform1.MultiOutput = false;
                        transform1.Transform(document1, list1, writer2);
                        string text3 = writer1.ToString();
                        text3 = text3.Replace("&lt;", "<");
                        text3 = text3.Replace("&gt;", ">");
                        output.Write(text3);
                    }
                    else
                    {
                        this.WriteError(output, "Warning: Need a XSL to render data");
                    }
                }
            }
            catch (Exception exception1)
            {
                this.WriteException(output, exception1);
                this.WriteError(output, this.w);
            }
            if (this.w.Length > 0)
            {
                this.WriteError(output, this.w);
            }
            if ((this.v.Length > 0) && this.doDebug)
            {
                this.WriteError(output, this.v);
            }
        }


        [DefaultValue(false), Category("RollUp"), WebPartStorage(Storage.Personal), FriendlyName("Dates in ISO8601"), Description("Dates in ISO8601"), Browsable(true)]
        public bool DateISO8601
        {
            get
            {
                return this.showIsoDate;
            }
            set
            {
                this.showIsoDate = value;
            }
        }

        [FriendlyName("Debug XML"), Category("RollUp"), DefaultValue(false), WebPartStorage(Storage.Personal), Browsable(true), Description("Show XML")]
        public bool Debug
        {
            get
            {
                return this.doDebug;
            }
            set
            {
                this.doDebug = value;
            }
        }
        [Description("Debug Query"), Browsable(true), Category("RollUp Query"), DefaultValue(false), WebPartStorage(Storage.Personal), FriendlyName("Debug Query")]
        public bool DebugQuery
        {
            get
            {
                return this.doDebugQuery;
            }
            set
            {
                this.doDebugQuery = value;
            }
        }
        [WebPartStorage(Storage.Personal), Description("Fields Names field,field, ..."), Category("RollUp"), DefaultValue(""), Browsable(true), FriendlyName("Fields")]
        public string Fields
        {
            get
            {
                return this.fields;
            }
            set
            {
                this.fields = value;
            }
        }
        [Browsable(true), Description("Fix Lookups"), Category("RollUp"), DefaultValue(false), WebPartStorage(Storage.Personal), FriendlyName("Fix Lookups")]
        public bool FixLookups
        {
            get
            {
                return this.fixLookups;
            }
            set
            {
                this.fixLookups = value;
            }
        }

        [Category("RollUp"), FriendlyName("Include List data"), Browsable(true), Description("Include the list data underscore fields"), DefaultValue(false), WebPartStorage(Storage.Personal)]
        public bool IncludeData
        {
            get
            {
                return this.includeData;
            }
            set
            {
                this.includeData = value;
            }
        }

        [Browsable(true), WebPartStorage(Storage.Personal), Category("RollUp"), DefaultValue(""), FriendlyName("Lists"), Description("Lists to rollup format /site/subsite:List,/site/subsite/List")]
        public string Lists
        {
            get
            {
                return this.lists;
            }
            set
            {
                this.lists = value;
            }
        }

        [Description(""), FriendlyName("Page Query String (ID)"), Browsable(false), Category("RollUp"), DefaultValue(""), WebPartStorage(Storage.Personal)]
        public string PageQueryString
        {
            get
            {
                return this.pageQueryString;
            }
            set
            {
                this.pageQueryString = value;
            }
        }

        [FriendlyName("CAML Query"), DefaultValue(""), WebPartStorage(Storage.Personal), Description("CAML Query"), Browsable(true), Category("RollUp Query")]
        public string Query
        {
            get
            {
                return this.query;
            }
            set
            {
                this.query = value;
            }
        }

        [DefaultValue(false), Description("Query Moderator"), Browsable(true), Category("RollUp Query"), WebPartStorage(Storage.Personal), FriendlyName("Query Moderator")]
        public bool QueryModerator
        {
            get
            {
                return this.queryModerator;
            }
            set
            {
                this.queryModerator = value;
            }
        }

        [WebPartStorage(Storage.Personal), Browsable(true), DefaultValue(false), Category("RollUp Query"), FriendlyName("Query Recursive"), Description("Query Recursive")]
        public bool QueryRecursive
        {
            get
            {
                return this.queryRecursive;
            }
            set
            {
                this.queryRecursive = value;
            }
        }

        [FriendlyName("CAML Query RowLimit"), Category("RollUp Query"), DefaultValue(""), WebPartStorage(Storage.Personal), Browsable(true), Description("CAML Query RowLimit")]
        public string QueryRowLimit
        {
            get
            {
                return this.queryRowLimit;
            }
            set
            {
                this.queryRowLimit = value;
            }
        }

        [Description("Rollup the content of lists list,list in all subsites"), Category("RollUp"), WebPartStorage(Storage.Personal), DefaultValue(false), Browsable(true), FriendlyName("Lists in all SubSites")]
        public bool SubSites
        {
            get
            {
                return this.subSites;
            }
            set
            {
                this.subSites = value;
            }
        }

        [FriendlyName("From Top Level"), Description(""), Browsable(true), Category("RollUp"), DefaultValue(""), WebPartStorage(Storage.Personal)]
        public string TopLevel
        {
            get
            {
                return this.topLevel;
            }
            set
            {
                this.topLevel = value;
            }
        }

        [FriendlyName("XSL"), WebPartStorage(Storage.Personal), Description("XSL to render RollUp"), Browsable(true), Category("RollUp"), DefaultValue("")]
        public string XSL
        {
            get
            {
                return this.xsl;
            }
            set
            {
                this.xsl = value;
            }
        }



    }

}
